* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: sans-serif;
}
body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: #222;
}
.zigzag{
    position: absolute;
    display: flex;
    gap: 38px;
}
.zigzag:nth-child(2){
    transform: rotate(180deg);
}
.zigzag div{
    position: relative;
    width: 100px;
    height: 100px;
    display: block;
    transform: rotate(315deg);
    overflow: hidden;
}
.zigzag div::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 2px;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, #0f0);
    animation: animateBefore 4s linear infinite;
    animation-delay: calc(1s * var(--i));
}
@keyframes animateBefore {
    0% {
        transform: translateX(-100%);
    }
    25%,100% {
        transform: translateX(100%);
    }
}
.zigzag div::after {
    content: '';
    position: absolute;
    right: 0;
    width: 2px;
    height: 100%;
    transform: translateY(-100%);
    background: linear-gradient(180deg, transparent, #0f0);
    animation: animateAfter 4s linear infinite;
    animation-delay: calc(1s * var(--i));
}
@keyframes animateAfter {
    0%,12.5% {
        transform: translateY(-100%);
    }
    37.5%,100% {
        transform: translateY(100%);
    }
}
.zigzag div span {
    position: absolute;
    inset: 10px;
    background: #292929;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid #000;
}
.zigzag div span b {
    color: #fff;
    font-weight: normal;
    transform: rotate(45deg);
}